package com.caine.algorithm;

import com.caine.algorithm.entity.User;
import com.caine.algorithm.mapper.UserMapper;
import com.caine.algorithm.sqlTool.MapperTool;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.List;

public class Mybatis02Application {
    public static void main(String[] args) throws Exception {
       /* List<User> users1 = MapperTool.callMapper(UserMapper.class, mapper -> {
            List<User> users = mapper.queryForList();
            return users;
        });
        users1.forEach(s -> {
            System.out.println(s.getId());
        });*/

       /* List<User> users = MapperTool.callMapper(UserMapper.class, t -> t.queryForList());
        users.forEach(s -> {
            System.out.println(s.getId());
        });*/
        SqlSessionFactory build = MapperTool.build();
        SqlSession sqlSession = build.openSession(true);
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        List<User> users = mapper.queryForList();
        System.out.println("users.toString() = " + users.toString());

    }
}
